﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
using Abp.Application.Services.Dto;
using Abp.AutoMapper;
using Abp.Domain.Entities.Auditing;
using FwProject.Authorization.Users;
using FwProject.ShoppingMall.Com;

namespace FwProject.Com.Dto
{
    /// <summary>
    /// 订单模型
    /// </summary>
    [AutoMap(typeof(ShopOrder))]
    public class ShopOrderDto: EntityDto<Guid>
    {
        /// <summary>
        /// 用户id
        /// </summary>
        [Display(Name = "用户编号")]
        public long UserId { get; set; }

        /// <summary>
        /// 订单编号
        /// </summary>
        [Display(Name = "订单号")]
        public string OrderNumber { get; set; }

        /// <summary>
        /// 支付状态
        /// </summary>
        [Display(Name = "支付状态")]
        public PayStatus PayStatus { get; set; } = PayStatus.未支付;

        /// <summary>
        /// 支付方式
        /// </summary>
        [Display(Name = "支付方式")]
        public PayType PayType { get; set; } = PayType.微信支付;


        /// <summary>
        /// 总支付金额
        /// </summary>
        [Display(Name = "总支付金额")]
        public decimal PayTotal { get; set; } = 0m;

        /// <summary>
        /// 优惠金额
        /// </summary>
        [Display(Name = "优惠金额")]
        public decimal PyaPreferentia { get; set; } = 0m;

        /// <summary>
        /// 应付总金额
        /// </summary>
        [Display(Name = "应付总金额")]
        public decimal PayAmount { get; set; } = 0m;

        /// <summary>
        /// 收货地址
        /// </summary>
        [Display(Name = "收货地址")]
        public Guid ReceivingAddress { get; set; }

        /// <summary>
        /// 付款时间
        /// </summary>
        [Display(Name = "付款时间")]
        public DateTime? PayTime { get; set; }

        /// <summary>
        /// 买家留言
        /// </summary>
        [Display(Name = "买家留言")]
        public string OrderLeavingMessage { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public long? CreatorUserId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public DateTime CreationTime { get; set; }
    }
    /// <summary>
    /// 订单输出模型
    /// </summary>
    [AutoMap(typeof(ShopOrder))]
    public class ShopOrderOutputDto:EntityDto<Guid>
    {
        /// <summary>
        /// 订单号
        /// </summary>
        public string OrderNumber { get; set; }

        /// <summary>
        /// 下单日期
        /// </summary>
        public DateTime CreationTime { get; set; }

        /// <summary>
        /// 发货日期
        /// </summary>
        public DateTime? DeliveryTime { get; set; }

        /// <summary>
        /// 订单总额
        /// </summary>
        public decimal PayTotal { get; set; }

        /// <summary>
        /// 实付金额
        /// </summary>
        public decimal PayAmount { get; set; }

        /// <summary>
        /// 收货人
        /// </summary>
        public ShopAppReceivingAddressDto ShopReceivingAddress { get; set; }

        /// <summary>
        /// 支付状态
        /// </summary>
        public PayStatus PayStatus { get; set; }


        /// <summary>
        /// 发货状态
        /// </summary>
        public DeliveryStatus DeliveryStatus { get; set; }

        /// <summary>
        /// 支付类型
        /// </summary>
        public PayType PayType { get; set; }


    }
    /// <summary>
    /// 订单确认模型
    /// </summary>
    public class ShopOrderHandleDto:EntityDto<Guid>
    {
        #region 基本信息
        /// <summary>
        /// 订单基本信息
        /// </summary>
        public ShopAppOrderInformationDto ShopOrderInformation { get; set; }

      
        #endregion

        #region 订单明细
        /// <summary>
        /// 订单明细
        /// </summary>
        public List<ShopOrderDetailsOutputDto> ShopOrderDetails { get; set; }
        
        #endregion

        #region 会员信息
        /// <summary>
        /// 会员信息
        /// </summary>
        public ShopAppUserDto ShopUser { get; set; }

      


    }
    /// <summary>
    /// 会员基本信息
    /// </summary>
    [AutoMapFrom(typeof(User))]
    public class ShopAppUserDto
    {
        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 电话
        /// </summary>
        public string Mobile { get; set; }

        /// <summary>
        /// 现住址
        /// </summary>
        public string NowAddress { get; set; }

        /// <summary>
        /// 邮箱
        /// </summary>
        public string EmailAddress { get; set; }

    }
    #endregion
    /// <summary>
    /// 订单基本信息模型
    /// </summary>
    [AutoMapFrom(typeof(ShopOrder))]
    public class ShopAppOrderInformationDto
    {
        /// <summary>
        /// 用户编号
        /// </summary>
        public long UserId { get; set; }

        /// <summary>
        /// 订单编号
        /// </summary>
        public string OrderNumber { get; set; }

        /// <summary>
        /// 支付状态
        /// </summary>
        public PayStatus PayStatus { get; set; }

        /// <summary>
        /// 支付方式
        /// </summary>
        public PayType PayType { get; set; }

        /// <summary>
        /// 总支付金额
        /// </summary>
        public decimal PayTotal { get; set; }

        /// <summary>
        /// 优惠金额
        /// </summary>
        public decimal PyaPreferentia { get; set; }

        /// <summary>
        /// 应付总金额
        /// </summary>
        public decimal PayAmount { get; set; }

        /// <summary>
        /// 付款时间
        /// </summary>
        public DateTime? PayTime { get; set; }

        /// <summary>
        /// 买家留言
        /// </summary>
        public string OrderLeavingMessage { get; set; }

        /// <summary>
        /// 下单日期
        /// </summary>
        public DateTime CreationTime { get; set; }

        public string ActualReceivingName { get; set; }
        public string ActualReceivingTel { get; set; }
        public string ActualReceivingAddress { get; set; }

        /// <summary>
        /// 收货人
        /// </summary>
        public ShopAppReceivingAddressDto ShopReceivingAddress { get; set; }
        /// <summary>
        /// 收货人模型
        /// </summary>
      
    }

    [AutoMap(typeof(ShopReceivingAddress))]
    public class ShopAppReceivingAddressDto 
    {
        /// <summary>
        /// 收货人姓名
        /// </summary>
        public string ReceivingName { get; set; }

        /// <summary>
        /// 收货电话
        /// </summary>
        public string ReceivingTel { get; set; }

        /// <summary>
        /// 收货地址
        /// </summary>
        public string ReceivingAddress { get; set; }
        /// <summary>
        /// 区域编码
        /// </summary>
        public string AreaId { get; set; }
    }

}
